﻿using System;
using System.Linq;
using Tss.MagicWeb.Domain.Cards;
using Tss.MagicWeb.Domain.Entities;

namespace Tss.MagicWeb.Domain.Decks
{
    public class MinimalCardCountDeckValidationRuleProvider : IDeckValidationRuleProvider
    {
        public Func<Deck, BasePhysicalCard, DeckValidationRuleResult> GetValidationRule()
        {
            // 100.2a In constructed play each deck must contain at least sixty cards.
            return
                (Deck x, BasePhysicalCard y) =>
                (
                    x.DeckItems.Sum(c => c.Amount) > 60
                        ? DeckValidationRuleResult.Successful()
                        : new DeckValidationRuleResult("Deck cannot contain less than 60 cards.")
                );
        }
    }
}
